//
//  AboutPage.swift
//  chat
//
//  Created by 1 on 2023/7/10.
//

import SwiftUI

struct AboutPage: View {
    @Environment(\.presentationMode) var presentationMode
    
    var body: some View {
        VStack{
            Image("img_logo")
                .padding(.top,44)
            HStack{
                Text("Version"+MBAInfo.getVersion())
                Text("("+MBAInfo.getBuild()+")")
            }
            .padding(.top,8)
            .font(.system(size: 14))
            .foregroundColor(MBAColor.com_gblue1.color)
            
            AboutPageCell(titleString: "检查更新")
                .contentShape(Rectangle())
                .onTapGesture {
                    MBAInfo.openAppStore()
                }
                .padding(.horizontal,24)
                .padding(.top,24)
            Spacer()
        }
        .frame(minWidth: 0,maxWidth: .infinity)
        .background(MBAColor.com_background.color)
        .navigationBarBackButtonHidden(true)
        .navigationBarItems(leading: QSNavigationBackButton(action: {
            self.presentationMode.wrappedValue.dismiss()
        })
        )
    }
}

struct AboutPageCell:View{
    var titleString = "检查更新"
    var body: some View{
        HStack(spacing: 0){
            Text(titleString)
                .font(.system(size: 16))
                .foregroundColor(MBAColor.com_white.color)
            Spacer()
            Image(systemName: "chevron.right")
                .font(.system(size: 12).bold())
                .foregroundColor(MBAColor.com_white.color)
        }
        .padding(.horizontal,16)
        .padding(.vertical,12)
        .background(MBAColor.com_textBg.color)
        .cornerRadius(8)
    }
}

struct AboutPage_Previews: PreviewProvider {
    static var previews: some View {
        AboutPage()
    }
}
